import React from 'react';
import { withRouter, Redirect } from 'react-router-dom'
import config from '@UTILS/config'
import './css/StarRating.less'

class StarRating extends React.PureComponent {
    constructor(props) {
        super(props)
        this.state = {
            starNum: this.props.starNum * 1,
            starAll: ['', '', '', '', '']
        }
    }


    render() {
        const selectColor = config.theme['color-text-theme']
        return (
            <span id="starBox">
                {
                    this.state.starAll.map((item, index) => {
                        if (index < this.state.starNum) {
                            return (
                                <i key={index} className="icon-shoucang iconfont" style={{
                                    color: selectColor
                                }}></i>
                            )
                        } else {
                            return (
                                <i key={index} className="icon-shoucang iconfont"></i>
                            )
                        }

                    })
                }
            </span>
        );
    }
}

export default withRouter(StarRating)